<script setup>
import { defineProps } from 'vue'

defineProps({
  userData: {
    type: Object
  },
  messageData: {
    type: Object
  },
  number: {
    type: Int16Array
  }
})
</script>

<template>
  <div class="box">
    <div class="left">
      <el-avatar :size="50" :src="userData.avatarImage" />
    </div>
    <div class="right">
      <div>
        <span style="font-size: 16px">{{ userData.username }}</span>
        <span style="margin-left: 7px; font-size: 13px">{{
          userData.companyName
        }}</span>
        <span style="font-size: 13px"> | </span>
        <span style="font-size: 13px">{{ userData.duties }}</span>
      </div>
      <div
        style="
          margin-top: 6px;
          font-size: 12px;
          color: #666;
          text-overflow: ellipsis;
          overflow: hidden;
          white-space: nowrap;
        "
      >
        <span style="color: #ccc; font-size: 16px; vertical-align: middle"
          ><el-icon><CircleCheckFilled /></el-icon
        ></span>
        <span style="margin-left: 2px">
          <span v-if="messageData.type === 0">{{ messageData.content }}</span>
          <span v-if="messageData.type === 1">[ 表情包 ]</span>
          <span v-if="messageData.type === 2">[ 图片 ]</span>
        </span>
      </div>
    </div>
    <div class="time">
      <div>{{ messageData.time.split(' ')[1] }}</div>
      <div class="icon" style="margin-top: 5px"></div>
      <div class="tag">
        <span v-if="number > 99">99+</span>
        <span v-if="number > 0">{{ number }}</span>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.box {
  display: flex;
  padding-top: 10px;
  padding-left: 15px;
  width: 320px;
  margin-left: 10px;
  margin-top: 15px;
  cursor: pointer;
  border-radius: 10px;
  .left {
    margin-right: 10px;
  }
  .right {
    width: 62%;
    margin-right: 5px;
  }
  .time {
    color: #999;
    font-size: 13px;
    margin-top: 3px;
    position: relative;
    .icon {
      width: 40px;
      height: 20px;
    }
  }
}
.box:hover {
  background-color: rgba($color: #ccc, $alpha: 0.1);
  .icon:after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background-image: url('http://121.40.171.110:9000/client-material/message.png'); /* 替换为您的图标路径 */
    background-size: cover;
  }
}
.tag {
  color: #fff;
  background-color: red;
  padding-left: 5px;
  padding-right: 5px;
  position: absolute;
  left: 23px;
  top: 30px;
  border-radius: 40px;
}
</style>
